#include <pthread.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <assert.h>
#include <sys/time.h>
#include <stdio.h>
#include "common.h"

extern "C" int create_task(char name[], task_func_t  func, void *param)
{
    pthread_t tid;
    pthread_attr_t attr;
    size_t stack_size = 1024 * 1024;
    if(pthread_attr_init(&attr) != 0)
        printf("pthread_attr_init.\n");

    pthread_attr_setstacksize(&attr, stack_size);

    if(pthread_create(&tid, &attr, func, param) != 0)
    {
        printf("create task [%s] error.\n", name);
        exit(-1);
    }

    pthread_attr_destroy(&attr);
    pthread_detach(tid);

    return 0;
}